<div [@routerTransition]>
    <div class="content d-flex flex-column flex-column-fluid">
        <sub-header [title]="'BrandCenter' | localize" [description]="'BrandCenter' | localize">
            <div role="actions">
                <div class="btn-group dropdown" dropdown *ngIf="isGranted('Pages.Tenant.Activities.Apply')">
                    <button class="btn btn-primary dropdown-toggle icon-piliangcaozuo" type="button" id="applyButton"
                        data-toggle="dropdown" dropdownToggle aria-haspopup="true" aria-expanded="false">
                        {{l('batchOperation')}}
                    </button>
                    <div class="dropdown-menu" *dropdownMenu aria-labelledby="applyButton" x-placement="bottom-start">
                        <a class="dropdown-item icon-shangxian1" (click)="online()">
                            {{l('onlineBatch')}}
                        </a>
                        <a class="dropdown-item icon-xiaxian1" (click)="offline()">
                            {{l('offlineBatch')}}
                        </a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item icon-shuminghaoshang_xian" (click)="onlineAll()">
                            {{l('onlineAll')}}
                        </a>
                        <a class="dropdown-item icon-shuminghaoxia_xian" (click)="offlineAll()">
                            {{l('offlineAll')}}
                        </a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item icon-piliangcaozuo" (click)="deleteBatch()">
                            {{l('deleteBatch')}}
                        </a>
                    </div>
                </div>
                <button class="btn btn-primary" (click)="createBrand()">
                    <i class="fa fa-plus"></i>
                    {{l("createBrand")}}</button>
            </div>
        </sub-header>


        <div [class]="containerClass">
            <div class="card card-custom gutter-b">
                <div class="card-body">
                    <form class="form" autocomplete="new-password">
                        <div>
                            <div class="row align-items-center mb-4">
                                <div class="col-3">
                                    <div class="form-group ">
                                        <div class="input-group">
                                            <input [(ngModel)]="filterText" name="filterText"
                                                (keyup.enter)="getBrands()" autoFocus class="form-control m-input "
                                                [placeholder]="l('BrandName')" type="text">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-3">
                                    <div class="form-group align-items-center">
                                        <div class="input-group">
                                            <select class="form-control" [(ngModel)]="tagId" name="tagType">
                                                <option value selected>{{l("All")}}</option>
                                                <option [value]="type.id" *ngFor="let type of tagList">
                                                    {{type.value}}</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-2">
                                    <div class="form-group align-items-center">
                                        <div class="input-group">
                                            <button type="button" class="btn btn-primary"
                                                [buttonBusy]="primengTableHelper.isLoading" (click)="getBrands()">
                                                <i class="la la-refresh"></i>
                                                {{l("search")}}
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                    <div class="row align-items-center">
                        <!--<Primeng-Datatable-Start>-->
                        <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                            <!-- resizableColumns="primengTableHelper.resizableColumns" -->
                            <p-table #dataTable id="tableShow" (onLazyLoad)="getBrands($event)"
                                [value]="primengTableHelper.records"
                                ScrollWidth="100%"
                                [rows]="primengTableHelper.defaultRecordsCountPerPage" [paginator]="false" [lazy]="true"
                                [(selection)]="brandPublishList"
                                [resizableColumns]="primengTableHelper.resizableColumns"
                                [responsive]="primengTableHelper.isResponsive">
                                <ng-template pTemplate="header">
                                    <tr>
                                        <th style="width:10%">{{l('Actions')}}</th>
                                        <th style="width: 5.0em">
                                            <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
                                        </th>
                                        <th style="width:5%">{{l('RecordId')}}</th>
                                        <th style="width:10%">{{l('logo')}}</th>
                                        <th style="width:10%">{{l('BrandName')}}</th>
                                        <th style="width:15%">{{l('slogan')}}</th>
                                        <th style="width:5%">{{l('tags')}}</th>
                                        <th style="width:15%">{{l('BrandThemeColor')}}</th>
                                        <th pSortableColumn="creationTime" style="width:15%">
                                            {{l('CreationTime')}}
                                            <p-sortIcon field="creationTime"></p-sortIcon>
                                        </th>
                                        <th style="width:10%">{{l('Status')}}</th>
                                    </tr>
                                </ng-template>
                                <ng-template pTemplate="body" let-record let-i="rowIndex">
                                    <tr>
                                        <td>
                                            <div class="btn-group dropdown" dropdown normalizePosition>
                                                <button class="dropdown-toggle btn btn-sm btn-primary"
                                                    data-toggle="dropdown" dropdownToggle aria-haspopup="true"
                                                    aria-expanded="false">
                                                    <i class="fa fa-cog"></i>
                                                    <span class="caret"></span> {{l("Actions")}}
                                                </button>
                                                <ul class="dropdown-menu" *dropdownMenu>
                                                    <li>
                                                        <a class="icon-bianji dropdown-item"
                                                            (click)="editBrand(record)">{{l('Edit')}}</a>
                                                    </li>
                                                    <li>
                                                        <a class="icon-icon-test dropdown-item" (click)="deleteBrand(record)"
                                                            *ngIf="record['auditStatus']==0">{{l('Delete')}}</a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </td>
                                        <td>
                                            <p-tableCheckbox [value]="record"></p-tableCheckbox>
                                        </td>
                                        <td>{{transIndex(i)}}</td>
                                        <td>
                                            <img [src]="fixFileUrl(record.logoUrl)" />
                                        </td>
                                        <td><span>{{record.name}}</span></td>
                                        <td><span>{{record.slogan}}</span></td>
                                        <td><span>
                                                <span *ngFor="let item of record.brandTags">
                                                    {{item.name}}
                                                </span>
                                            </span></td>
                                        <td>
                                            <i [ngStyle]="{'color':record.mainColor||'#000'}">{{record.mainColor}}</i>
                                        </td>
                                        <td>{{record.creationTime | date:'yyyy-MM-dd'}}</td>
                                        <td>
                                            <span *ngIf="record['auditStatus']==1"
                                                class="label label-success label-inline">{{l("online")}}</span>
                                            <span *ngIf="record['auditStatus']==0"
                                                class="label label-dark label-inline">{{l("offline")}}</span>
                                        </td>
                                    </tr>
                                </ng-template>
                                <ng-template pTemplate="emptymessage" let-records>
                                    <tr *ngIf="primengTableHelper.records">
                                        <td colspan="8" class="text-center">
                                            <img class="emptymessage"
                                                src="/assets/common/images/placeholder/brandHolder.png" />
                                        </td>
                                    </tr>
                                </ng-template>

                            </p-table>
                            <!-- <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                                {{'NoData' | localize}}
                            </div> -->
                            <div class="primeng-paging-container">
                                <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #paginator
                                    (onPageChange)="getBrands($event)"
                                    [totalRecords]="primengTableHelper.totalRecordsCount"
                                    [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">
                                </p-paginator>
                                <span class="total-records-count">
                                    {{l('TotalRecordsCount', primengTableHelper.totalRecordsCount)}}
                                </span>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>


    </div>


</div>